import { type TreeOption } from "@/components/MiniBpmn/types";
import { getDepartmentList } from '@/components/MiniBpmn/api';

class DepartmentData {
  options: TreeOption[] = [];

  async initData() {
    const res = await getDepartmentList();
    if (res) {
      const treeMap = (item: any): TreeOption => {
        return {
          label: item.name,
          value: item.id,
          children: item.children?.map(treeMap),
        };
      };
      this.options = (res.data || []).map(treeMap);
    } else {
      this.options = [];
    }
  }
}

export default DepartmentData;